
public class Manager {
	Board board;
	int turn;
	Manager(int size)
	{
		board = new Board(size);
		turn = 1;
	}
	
	int someoneWon()
	{
		if(board.numBlack == 0)
			return -1;	//player two wins
		else if(board.numWhite == 0)
			return 1;	//player one wins
		
		if(board.noMoreValidMoves(-1) && board.noMoreValidMoves(1))
		{
			if(board.numBlack > board.numWhite)
				return 1;
			else if(board.numBlack < board.numWhite)
				return -1;
			else
				return 2;	// Draw
		}
		return 0;	// No winner yet
	}
	
	// Inserts a piece. Returns true if succeeded, else false. 
	boolean insertPiece(int x, int y)
	{
		if( x < 0 || y < 0)
			return false;
		
		if(board.isValidMove(x, y, turn))
		{
			System.out.println("valid move");
			board.insertPiece(x, y, turn);
			if(!board.noMoreValidMoves(-turn))	// the next player CAN go
				turn = -turn;
			
			return true;
				
		}
		System.out.println("Not valid move");
		return false;
	}
}
